package com.hx.springboot1.config;

import com.hx.springboot1.utils.VerifyServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/loginPage").setViewName("loginPage");
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/index").setViewName("index");
        registry.addViewController("/stuList").setViewName("manage/stuList");
        registry.addViewController("/teacherList").setViewName("manage/teacherList");
        registry.addViewController("/courseList").setViewName("manage/courseList");
        registry.addViewController("/scoreList").setViewName("manage/scoreList");
        registry.addViewController("/accountList").setViewName("manage/accountList");
        registry.addViewController("/roleList").setViewName("manage/roleList");
        registry.addViewController("/chooseCourse").setViewName("reportForms/chooseCourse");
        registry.addViewController("/scoreReport").setViewName("reportForms/scoreReport");
    }
    @Bean  // 国际化请求， 将 地区解析器 注册到 springmvc容器中
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
    @Bean
    public ServletRegistrationBean indexServletRegistration(){
        ServletRegistrationBean registration = new ServletRegistrationBean(new VerifyServlet());
        registration.addUrlMappings("/getVerifyCode");
        return registration;
        }
}
